package cn.zc.curriculum.service.controller.admin;

import cn.tools.core.VO.PageVO;
import cn.tools.core.base.R;
import cn.zc.curriculum.entity.Dto.CurriculumMenuDto;
import cn.zc.curriculum.service.service.CurriculumMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "后台目录管理接口")
@RestController
@RequestMapping("/curriculum")
public class AdminCurriculumMenuController {


    @Resource
    private CurriculumMenuService curriculumMenuService;




    /**
     * 根据课程大类查询目录，用于后台创建时能第一时间查询出来
     * @param pageVO
     * @param classifyId
     * @return
     */
    @ApiOperation(value = "根据课程大类查询目录,只查询出目录用于后台创建目录后第一时间展示")
    @GetMapping("/admin/find/CurriculumMenu")
    private R<Object> findCurriculumMenuByClassify(PageVO pageVO, String classifyId){
        List<CurriculumMenuDto> curriculumMenuDto = curriculumMenuService.findCurriculumMenuByClassify(pageVO,classifyId);
        return R.success(curriculumMenuDto);
    }


    /**
     * 修改目录
     * @param curriculumMenuDto
     * @return
     */
    @ApiOperation(value = "修改目录")
    @PutMapping("/admin/update/CurriculumMenu")
    private R updateCurriculumMenu(@RequestBody CurriculumMenuDto curriculumMenuDto){
        curriculumMenuService.updateCurriculumMenu(curriculumMenuDto);
        return R.success();
    }

    /**
     * 删除目录
     * @param menuId
     * @return
     */
    @ApiOperation(value = "删除目录")
    @DeleteMapping("/admin/delete/CurriculumMenu")
    private R deleteCurriculumMenu(String menuId){
        curriculumMenuService.deleteCurriculumMenu(menuId);
        return R.success();
    }


    /**
     * 创建目录
     * @param curriculumMenuDto
     * @return
     */
    @ApiOperation(value = "创建目录")
    @PostMapping("/admin/create/CurriculumMenu")
    private R<Object> createCurriculumMenu(@RequestBody CurriculumMenuDto curriculumMenuDto){
        CurriculumMenuDto menu = curriculumMenuService.createCurriculumMenu(curriculumMenuDto);
        return R.success(menu);
    }




}
